package com.wande.dataplatform.common.enums;

/**
 * 数据中台错误码枚举
 *
 * @author ruoyi
 */
public enum DataPlatformErrorCode {

    // 数据源相关 (10xxx)
    DATASOURCE_NOT_FOUND(10001, "数据源不存在"),
    DATASOURCE_CONNECTION_FAILED(10002, "数据源连接失败"),
    DATASOURCE_ALREADY_EXISTS(10003, "数据源已存在"),
    DATASOURCE_TYPE_NOT_SUPPORTED(10004, "不支持的数据源类型"),
    DATASOURCE_CONFIG_INVALID(10005, "数据源配置无效"),

    // ETL相关 (11xxx)
    ETL_TASK_NOT_FOUND(11001, "ETL任务不存在"),
    ETL_EXECUTION_FAILED(11002, "ETL任务执行失败"),
    ETL_CONFIG_INVALID(11003, "ETL配置无效"),
    ETL_NODE_TYPE_INVALID(11004, "ETL节点类型无效"),
    ETL_TRANSFORM_FAILED(11005, "数据转换失败"),

    // 数据服务相关 (12xxx)
    API_NOT_FOUND(12001, "API不存在"),
    API_NOT_PUBLISHED(12002, "API未发布"),
    API_RATE_LIMIT_EXCEEDED(12003, "API调用频率超限"),
    API_AUTH_FAILED(12004, "API鉴权失败"),
    API_PARAM_INVALID(12005, "API参数无效"),
    API_EXECUTION_FAILED(12006, "API执行失败"),

    // 数据质量相关 (13xxx)
    CHECK_RULE_NOT_FOUND(13001, "稽查规则不存在"),
    CLEAN_RULE_NOT_FOUND(13002, "清洗规则不存在"),
    QUALITY_CHECK_FAILED(13003, "数据质量检查失败"),
    QUALITY_CLEAN_FAILED(13004, "数据清洗失败"),

    // Doris相关 (14xxx)
    DORIS_CONNECTION_FAILED(14001, "Doris连接失败"),
    DORIS_DATABASE_NOT_FOUND(14002, "Doris数据库不存在"),
    DORIS_TABLE_NOT_FOUND(14003, "Doris表不存在"),
    DORIS_QUERY_FAILED(14004, "Doris查询失败"),
    DORIS_DDL_FAILED(14005, "Doris DDL执行失败"),
    DORIS_SYNC_FAILED(14006, "Doris元数据同步失败"),

    // DolphinScheduler相关 (15xxx)
    DS_CONNECTION_FAILED(15001, "DolphinScheduler连接失败"),
    DS_WORKFLOW_NOT_FOUND(15002, "工作流不存在"),
    DS_WORKFLOW_CREATE_FAILED(15003, "工作流创建失败"),
    DS_WORKFLOW_START_FAILED(15004, "工作流启动失败"),
    DS_WORKFLOW_STOP_FAILED(15005, "工作流停止失败"),

    // 元数据相关 (16xxx)
    METADATA_NOT_FOUND(16001, "元数据不存在"),
    METADATA_COLLECT_FAILED(16002, "元数据采集失败"),
    LINEAGE_BUILD_FAILED(16003, "血缘关系构建失败"),

    // 数据模型相关 (17xxx)
    DATA_MODEL_NOT_FOUND(17001, "数据模型不存在"),
    DATA_MODEL_INVALID(17002, "数据模型定义无效"),
    DATA_MODEL_SYNC_FAILED(17003, "数据模型同步失败"),

    // 作业管理相关 (18xxx)
    JOB_NOT_FOUND(18001, "作业不存在"),
    JOB_EXECUTION_FAILED(18002, "作业执行失败"),
    JOB_DAG_INVALID(18003, "作业DAG配置无效"),
    JOB_INSTANCE_NOT_FOUND(18004, "作业实例不存在"),

    // 项目管理相关 (19xxx)
    PROJECT_NOT_FOUND(19001, "项目不存在"),
    PROJECT_MEMBER_NOT_FOUND(19002, "项目成员不存在"),
    PROJECT_PERMISSION_DENIED(19003, "无项目权限"),

    // 数据开发相关 (20xxx)
    DEV_TASK_NOT_FOUND(20001, "数据开发任务不存在"),
    DEV_TASK_EXECUTION_FAILED(20002, "任务执行失败"),
    DEV_TEMPLATE_NOT_FOUND(20003, "模板不存在"),
    DEV_INSTANCE_NOT_FOUND(20004, "任务实例不存在"),

    // 报表相关 (21xxx)
    REPORT_NOT_FOUND(21001, "报表不存在"),
    REPORT_CONFIG_INVALID(21002, "报表配置无效"),
    REPORT_EXPORT_FAILED(21003, "报表导出失败"),
    CHART_NOT_FOUND(21004, "图表不存在"),
    CHART_DATA_QUERY_FAILED(21005, "图表数据查询失败"),

    // 通用错误 (22xxx)
    SYSTEM_ERROR(22001, "系统错误"),
    PARAM_INVALID(22002, "参数无效"),
    OPERATION_NOT_ALLOWED(22003, "操作不允许"),
    RESOURCE_NOT_FOUND(22004, "资源不存在"),
    TENANT_ISOLATION_ERROR(22005, "租户隔离错误");

    private final int code;
    private final String message;

    DataPlatformErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}
